package org.example.pattern.chain.factory;

import org.example.pattern.chain.handler.*;

/**
 * beyond u self and trust u self.
 *
 * @Author: lbc
 * @Date: 2023-05-12 10:52
 * @email: 594599620@qq.com
 * @Description: oh my god！ niu bi...
 */
public class GatewayHandlerFactory {

    public static GatewayHandler getFirstGatewayHandler(){
        //api接口限流
        GatewayHandler apiLimitGetewayHandler = new ApiLimitGatewayHandler();
        //黑名单拦截
        GatewayHandler blacklistGetwayHandler = new BlacklistGatewayHandler();
        //用户会话拦截
        GatewayHandler sessionGetwayHandler = new SessionGatewayHandler();
        //参数过滤
        GatewayHandler paramGetwayHandler = new ParamGatewayHandler();

        apiLimitGetewayHandler.setNext(blacklistGetwayHandler);//api接口限流的下一步是黑名单拦截
        blacklistGetwayHandler.setNext(sessionGetwayHandler);//杯名单拦截的下一步是用户会话拦截
        sessionGetwayHandler.setNext(paramGetwayHandler);//用户会话拦截的下一步是参数果过滤拦截

        return apiLimitGetewayHandler;
    }

}
